package com.dmtt.web.are.controller;

import com.dmtt.util.BaseController;
import com.dmtt.web.are.entity.AreSynchronized;
import com.dmtt.web.are.service.AreSynchronizedService;
import com.dmtt.web.are.vo.AreSynchronizedVo;
import com.dmtt.web.are.vo.QueryParamsVo;
import com.dmtt.web.entity.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author guzhenbiao
 * @project dmtt
 * @package com.dmtt.web.are.controller
 * @className AreSynchronizedController
 * @description TODO
 * @since2022/8/6 12:48
 * @version1.0
 */
@RestController
@RequestMapping(value = "/areSynchronized")
public class AreSynchronizedController extends BaseController {

    @Autowired
    private AreSynchronizedService areSynchronizedService;


    /**
     * @Description: 区域锁的列表加分页
     * @param:[currentPage, limit, areName, currAgvName]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-220 15:29:22
     */
    @PostMapping(value="/queryAreSynchronizedByPage")
    public ResponseEntity<?> queryAreSynchronizedByPage(@RequestBody QueryParamsVo queryParamsVo){
        return backResponse(areSynchronizedService.queryAreSynchronizedByPage(queryParamsVo));
    }

    /**
     * @Description: 区域锁新增
     * @param:[areSynchronizedVo, request]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-218 15:12:22
     */
    @PostMapping(value="/insertAreSynchronized")
    public ResponseEntity<?> insertAreSynchronized(@RequestBody AreSynchronizedVo areSynchronizedVo,HttpServletRequest request){
        return backResponse(areSynchronizedService.insertAreSynchronized(areSynchronizedVo,super.getUser(request)));
    }

    /**
     * @Description:  区域锁更新
     * @param:[areSynchronizedVo, request]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-220 15:29:13
     */
    @PostMapping(value="/updateAreSynchronized")
    public ResponseEntity<?> updateAreSynchronized(@RequestBody AreSynchronizedVo areSynchronizedVo,HttpServletRequest request){
        return backResponse(areSynchronizedService.updateAreSynchronized(areSynchronizedVo,super.getUser(request)));
    }

    /**
     * @Description: 区域锁禁用
     * @param:[id, status, request]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-220 15:31:06
     */
    @PostMapping(value="/disableAreSynchronizedById")
    public ResponseEntity<?> disableAreSynchronizedById(@RequestBody QueryParamsVo queryParamsVo, HttpServletRequest request){
        return backResponse(areSynchronizedService.disableAreSynchronizedById(queryParamsVo,super.getUser(request)));
    }

    /**
     * @Description: 区域锁查看
     * @param:[id]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-220 15:32:04
     */
    @PostMapping(value="/getAreSynchronizedById")
    public ResponseEntity<?> getAreSynchronizedById(@RequestBody QueryParamsVo queryParamsVo){
        return backResponse(areSynchronizedService.getAreSynchronizedById(queryParamsVo));
    }

    /**
     * @Description: 获取区域锁历史信息列表加分页
     * @param:[currentPage, limit, areName, agvName]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-220 15:41:52
     */
    @PostMapping(value="/queryAreSynchronizedHistoryByPage")
    public ResponseEntity<?> queryAreSynchronizedHistoryByPage(@RequestBody QueryParamsVo queryParamsVo){
        try {
            return backResponse(areSynchronizedService.queryAreSynchronizedHistoryByPage(queryParamsVo));
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }


    /**
     * @Description: 获取agv供应商集合
     * @param:[]
     * @return: org.springframework.http.ResponseEntity<?>
     * @Author: guzhenbiao
     * @Date: 2022-08-227 09:15:16
     */
    @PostMapping(value="/getAgvCompanyList")
    public ResponseEntity<?> getAgvCompanyList(){
        return backResponse(areSynchronizedService.getAgvCompanyList());
    }

}
